import React from 'react'
import { useState, useEffect } from 'react';
import { useLocation } from 'react-router';
import { pageTitle } from '../../config'

export default function Header(props) {
    // const { title = '饿了么' } = props;
    const [title, setTitle] = useState('首页')
    const { pathname = '/' } = useLocation()
    useEffect(() => {
        // const location = window.location.pathname;
        let _title = pageTitle[pathname] || ''; // 放入配置文件config中
        // if (pathname == '/order') {
        //     _title = '订单页面'
        // } else if (pathname == '/home' || location == '/') {
        //     _title = '饿了么'
        // }
        setTitle(_title)
    })
    return (
        <header>
            {title}
        </header>
    )
}
